//
//  SISSNetworkingManager.h
//  SISSAPP
//
//  Created by 优房网 on 2017/3/21.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import <AFNetworking/AFNetworking.h>
#import "UIImage+Compression.h"

#import "SISSEntrustContractModel.h"

#define kNetworkManager [SISSNetworkingManager sharedManager]
#define kNetworkNoUTF8Manager [SISSNetworkingManager noUTF8Manager]
#define kNetworkNoBaseUrlManager [SISSNetworkingManager noBaseUrlManager]


typedef NS_ENUM(NSUInteger, HTTPMethod) {
    
    HTTPMethodGET,
    HTTPMethodPOST,
    HTTPMethodpUT,
    HTTPMethodPATCH,
    HTTPMethodDELETE,
};

@interface SISSNetworkingManager : AFHTTPSessionManager


/**
 *  单例
 *
 *  @return 实例对象
 */
+ (instancetype)sharedManager;

/// user模块baseUrl
+ (instancetype)noUTF8Manager;

+ (instancetype)noBaseUrlManager;

/**
 *  网络请求工具类GET请求的主方法
 *
 *  @param URLString 请求地址
 *  @param parameters 请求参数
 *  @param success   成功的回调
 *  @param failure     失败的回调
 */
- (void)GETWithURLString:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void(^)(id responseObject))success failure:(void(^)(NSError *error))failure;

/**
 *  网络请求工具类POST请求的主方法
 *
 *  @param URLString 请求地址
 *  @param parameters 请求参数
 *  @param success   成功的回调
 *  @param failure     失败的回调
 */
- (void)POSTWithURLString:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void(^)(id responseObject))success failure:(void(^)(NSError *error))failure;

/**
 *  网络请求工具类PUT请求的主方法
 *
 *  @param URLString 请求地址
 *  @param parameters 请求参数
 *  @param success   成功的回调
 *  @param failure     失败的回调
 */
- (void)PUTWithURLString:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void(^)(id responseObject))success failure:(void(^)(NSError *error))failure;

/**
 *  网络请求工具类DELETE请求的主方法
 *
 *  @param URLString 请求地址
 *  @param parameters 请求参数
 *  @param success   成功的回调
 *  @param failure     失败的回调
 */
- (void)DELETEWithURLString:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void(^)(id responseObject))success failure:(void(^)(NSError *error))failure;

// 上传多个文件,带文字信息
- (void)uploadFilesWithURLStr:(NSString *)URLStr serverName:(NSString *)serverName imagesArray:(NSArray *)imagesArray parameters:(NSDictionary *)parameters success:(void(^)(id responseObject))successBlock failed:(void(^)(NSError *error))failedBlock;


/**
 上传多个文件

 @param URLStr urlStr
 @param serverNames serverName数组
 @param imagesArray 对应图片数组
 @param parameters 参数
 @param successBlock 成功的回调
 @param failedBlock 失败的回调
 */
- (void)uploadFilesWithURLStr:(NSString *)URLStr serverNames:(NSArray<NSString *> *)serverNames imagesArray:(NSArray<NSArray *> *)imagesArray parameters:(NSDictionary *)parameters success:(void(^)(id responseObject))successBlock failed:(void(^)(NSError *error))failedBlock;

#pragma mark - GET 请求网络数据
/**
 *  请求网络数据
 *
 *  @param path             请求的地址
 *  @param paramters        请求的参数
 *  @param downLoadProgress 进度
 *  @param success          请求成功的回调
 *  @param failure          请求失败的回调
 */
- (void)GETDataWithPath:(NSString *)path
                 withParamters:(NSDictionary *)paramters
                  withProgress:(void(^) (float progress))downLoadProgress
                       success:(void(^) (BOOL isSuccess, id responseObject))success
                       failure:(void(^) (NSError *error))failure ;

#pragma mark - POST 传送网络数据
/**
 *  传送网络数据
 *
 *  @param path           请求的地址
 *  @param paramters      请求的参数
 *  @param upLoadProgress 进度
 *  @param success        请求成功的回调
 *  @param failure        请求失败的回调
 */
- (void)POSTDataWithPath:(NSString *)path
               withParamters:(NSDictionary *)paramters
                withProgress:(void(^) (float progress))upLoadProgress
                     success:(void(^) (BOOL isSuccess, id responseObject))success
                     failure:(void(^) (NSError *error))failure ;

#pragma mark POST 上传图片
/**
 *  上传图片
 *
 *  @param path           上传的地址--需要填写完整的url
 *  @param paramters      上传图片预留参数--根据具体需求而定，可以出
 *  @param imageArray     上传的图片数组
 *  @param width          图片要被压缩到的宽度
 *  @param upLoadProgress 进度
 *  @param success        请求成功的回调
 *  @param failure        请求失败的回调
 */
- (void)POSTImageWithPath:(NSString *)path
                withParamters:(NSDictionary *)paramters
               withImageArray:(NSArray *)imageArray
              withtargetWidth:(CGFloat )width
                 withProgress:(void(^) (float progress))upLoadProgress
                      success:(void(^) (BOOL isSuccess, id responseObject))success
                      failure:(void(^) (NSError *error))failure ;

#pragma mark POST 上传视频
/**
 *  上传视频
 *
 *  @param path           上传的地址--需要填写完整的url
 *  @param videoPath      上传的视频--本地沙盒的路径
 *  @param paramters      上传视频预留参数--根据具体需求而定，可以出
 *  @param upLoadProgress 进度
 *  @param success        请求成功的回调
 *  @param failure        请求失败的回调
 */
- (void)POSTImageWithPath:(NSString *)path
                withVideoPath:(NSString *)videoPath
                withParamters:(NSDictionary *)paramters
                 withProgress:(void(^) (float progress))upLoadProgress
                      success:(void(^) (BOOL isSuccess, id responseObject))success
                      failure:(void(^) (NSError *error))failure ;

#pragma mark DOWNLOAD 文件下载
- (void)DownLoadDataWithPath:(NSString *)path
                      withParamters:(NSDictionary *)paramters
                       withSavaPath:(NSString *)savePath
                       withProgress:(void(^) (float progress))downLoadProgress
                            success:(void(^) (BOOL isSuccess, id responseObject))success
                            failure:(void(^) (NSError *error))failure ;

#pragma mark - DELETE 删除资源
- (void)DELETEDataWithPath:(NSString *)path
                    withParamters:(NSDictionary *)paramters
                          success:(void (^) (BOOL isSuccess, id responseObject))success
                          failure:(void (^) (NSError *error))failure ;

#pragma mark - PUT 更新全部属性
- (void)PUTDataWithPath:(NSString *)path
              withParamters:(NSDictionary *)paramters
                    success:(void(^) (BOOL isSuccess, id responseObject))success
                    failure:(void(^) (NSError *error))failure ;

#pragma  mark - PATCH 改变资源状态或更新部分属性
- (void)PATCHDataWithPath:(NSString *)path
                withParamters:(NSDictionary *)paramters
                      success:(void (^) (BOOL isSuccess, id responseObject))success
                      failure:(void (^) (NSError *error))failure ;

#pragma mark - 取消网络请求--全部请求
- (void)cancelAllNetworkRequest ;

#pragma mark - 取消网络请求--指定请求
/**
 *  取消指定的url请求
 *
 *  @param type 该请求的请求类型
 *  @param path 该请求的完整url
 */
-(void)cancelHttpRequestWithType:(NSString *)type WithPath:(NSString *)path ;



@end
